package net.sppan.base.service.impl;

import net.sppan.base.dao.IEquipmentDao;
import net.sppan.base.entity.Employee;
import net.sppan.base.entity.Equipment;
import net.sppan.base.service.EquipmentService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/** 
 * @Description: 仪器
 * @Param:  
 * @return:  
 */
@Service
public class EquipmentServiceImpl implements EquipmentService {
	@Autowired
	private IEquipmentDao iEquipmentDao;
	@Override
	public List<Equipment> getEquipmentList(String equipmentCode) {
		return iEquipmentDao.getEquipmentList(equipmentCode);
	}

	@Override
	public List<Equipment> getLessDevice() {
		List<Equipment> list = iEquipmentDao.getLessDevice();
		List<Equipment> resultList = new ArrayList<>();
		if(CollectionUtils.isNotEmpty(list)){
		for(Equipment equipment : list){
			if(equipment.getLessNum() != null && equipment.getLessNum() != 0){
				resultList.add(equipment);
			}
		}
		}
		return resultList;
	}

	@Override
	public List<Employee> getEmployeeList() {
		return iEquipmentDao.getEmployeeList();
	}

	@Override
	public int addEquipment(Equipment equipment) {
		return iEquipmentDao.addEquipment(equipment);
	}

	@Override
	public int rent(Equipment equipment) {
		return iEquipmentDao.rent(equipment);
	}

	@Override
	public List<Equipment> getRentEquipmentList(String equipmentCode) {
		return iEquipmentDao.getRentEquipmentList(equipmentCode);
	}

	@Override
	public int returnEquipment(Equipment equipment) {
		return iEquipmentDao.returnEquipment(equipment);
	}
}
